package com.xu.demo.decoratorPattern;

public class DecoratorPattern {

    public static void main(String[] args) {

        Component component = new ConcreteComponent();
        // 使用装饰者A增强功能
        component = new ConcreteDecoratorA(component);
        // 使用装饰者B进一步增强功能
        component = new ConcreteDecoratorB(component);

        /*
         执行操作，会依次调用
         ConcreteComponent的operation、
         ConcreteDecoratorA的addedFunctionA、
         ConcreteDecoratorB的addedFunctionB
         */
        component.operation();
    }
}
